package com.util;

import com.qiniu.util.Auth;
import com.qy.util.RedisPoolMgr;

public class QingNiuUtil {
	private  static String accessKey = "UEU0Vrb6TluJSBcK53IjPeMy611Dm-IpJuzSFUbt";
	private  static String secertKey = "QDseQK_aH1dXWXODQl6mHiNbSrB1KflulI9HYSXp";
	private static String bucket="baoshangchewu";
	private static String key="BSCW_QN_TOKEN";
	private static int expires = 60*60;
	/**
	 * 青牛生成上传的token
	 * @return
	 */
	public static String getUploadToken(){
		String token = (String) RedisPoolMgr.get(key, String.class);
		if(token==null||token.isEmpty()||token.equals("null")){
			Auth auth = Auth.create(accessKey, secertKey);
			token = auth.uploadToken(bucket);
			RedisPoolMgr.set(key, token,expires);
		}

		return token;
	}
	
	public static void main(String[] args) {
	    System.out.println(QingNiuUtil.getUploadToken());
	}
}
